import os

def rename(dir_path,pre_fix):
    file_list = []
    r = ''
    for root, dirs, files in os.walk(dir_path):
        for file in files:
            if file.endswith("jpg") or file.endswith("png") or file.endswith("txt"):
                os.rename(os.path.join(root, file),os.path.join(root, pre_fix+file) )


if __name__ == '__main__':
    str_ = "26"
    path = '''D:\\Program\\yolov5\\Yolov5_StrongSORT_OSNet\\yolov5\\datasets\\uav\\set4\\online_drone_dataset\\image&label-20220708T015451Z-001\\image_label\\'''+str_
    rename(path,"26")